#version 150

struct Light
{
	vec3 pos;
	float power;
	vec3 color;
};

const int MAX_LIGHTS = 4;

in vec3 position;
in vec2 texcoord;
in vec3 normal;

out vec2 Texcoord;
out vec3 VertexPos_World;
out float Depth;
out vec3 Normal_Cam;
out vec3 EyeDir_Cam;
out vec3 LightDir_Cam[MAX_LIGHTS];

uniform float FCP;
uniform int lightCount;
uniform Light lights[MAX_LIGHTS];
uniform mat4 model;
uniform mat4 view;
uniform mat4 modelView;
uniform mat4 modelViewProj;

void main() 
{
	gl_Position = modelViewProj * vec4(position, 1.0);
	Texcoord = texcoord;
	VertexPos_World = (model * vec4(position, 1.0)).xyz;	
	Depth = gl_Position.z / FCP;
	Normal_Cam = (modelView * vec4(normal, 0.0)).xyz;
				
	vec3 vertexPos_Cam = (modelView * vec4(position, 1.0)).xyz;
	EyeDir_Cam = vec3(0.0, 0.0, 0.0) - vertexPos_Cam;
	
	for (int i = 0; i < lightCount; ++i)
	{
		vec3 lightPos_Cam = (modelView * vec4(lights[i].pos, 1.0)).xyz;
		LightDir_Cam[i] = lightPos_Cam - vertexPos_Cam;
	}
}